
package com.example;

import java.util.Arrays;

/**
 * @author Securitit.
 * @note SM4Util测试类.
 */
public class SM4UtilTester {

    // public static void main(String[] args) throws Exception {
    // String sm4Key = "123";
    // String plainText = "123";
    // String cipherText = null;

    // System.out.println("----------------------- 获取SM4秘钥
    // -------------------------");
    // // sm4Key = SM4Util.generateSm4Key();
    // System.out.println("秘钥：" + sm4Key);
    // System.out.println();
    // System.out.println("----------------------- 文本加解密测试
    // -------------------------");
    // // 文本加解密测试.
    // System.out.println("明文：" + plainText);
    // cipherText = SM4Util.encodeText(plainText, sm4Key);
    // System.out.println("密文：" + cipherText);
    // plainText = SM4Util.decodeText(cipherText, sm4Key);
    // System.out.println("解密明文：" + plainText);
    // System.out.println();
    // System.out.println("----------------------- 字节数组加解密测试
    // -------------------------");
    // // 字节数组加解密测试.
    // byte[] plainBytes = plainText.getBytes("UTF-8");
    // byte[] cipherBytes = null;
    // System.out.println("明文：" + Arrays.toString(plainBytes));
    // cipherBytes = SM4Util.encodeBytes(plainBytes, sm4Key);
    // System.out.println("密文：" + Arrays.toString(cipherBytes));
    // plainBytes = SM4Util.decodeBytes(cipherBytes, sm4Key);
    // System.out.println("解密明文：" + Arrays.toString(plainBytes));
    // System.out.println();
    // }

    public static void main(String[] args) throws Exception {

        System.out.println("========================= SM4UtilTester =========================");

        String data = "123";
        String key = "903B2CBD-D669-47E3-A6D9-94655C72B3BB";

        String encryptData = SM4Util.encodeText(data, key);

        System.out.println("加密结果:" + encryptData);
    }
}
